Figures in {ggplot}

An Bui

Today

  • General rules for data visualization
  • Design soapbox
  • Resources (not covered, just collected)
  • Playing around with code

General rules for data visualization

General rule #1: Convey the message

  • Legends and labels
  • Legible text, symbols, etc.
  • Clearly visible data
  • Intuitive color scheme
  • Redundancy

Source: palmerpenguins package

General rule #2: Minimize noise

  • Use colors sparingly (color-blind friendly choices are great too)
  • Minimize crowding

Source: palmerpenguins package

Design soapbox

Design soapbox

  • Figures can’t always be reused
  • Make your friends critique your figures
  • Kill your darlings
  • Always consider the audience!

Resources

General Data Visualization
- Fundamentals of Data Visualization, by Claus O. Wilke
- R for Data Science (Ch. 3), by Garrett Grolemund & Hadley Wickham
- A ggplot2 grammar guide, by Gina Reynolds
- ggplot2 cheat sheet
- ggplot2: Elegant Graphics for Data Analysis, by Hadley Wickham

Plot themes/customization
- Modifying components of a theme
- Themes to Improve your ggplot Figures, by David Keyes

Packages
- patchwork (for putting plots together)
- cowplot (also for putting plots together)
- ggtext package (improved text rendering support for ggplot2)

Other
- stat_summary() tutorial, by Christian Burkhart

On to the code!